<template>
	<el-col :span="componentModel.col" @click.stop="onClickHandler()" style="text-align: center;width:100%;position: relative;">
		<i class="el-icon-rank drag-widget" style="position: absolute;left: 0px;top:0px;z-index: 100;" v-show="selected"></i>
		<div style="text-align: left;border-bottom: 1px solid #ddd;">{{componentModel.title}}</div>
		<el-row>
			<el-col :span="8">
				<img src='../../../../../../assets/menu-item.png' style="width:28px;height:28px;" />
				<div>菜单1</div>
			</el-col>
			<el-col :span="8">
				<img src='../../../../../../assets/menu-item.png' style="width:28px;height:28px;" />
				<div>菜单2</div>
			</el-col>
			<el-col :span="8">
				<img src='../../../../../../assets/menu-item.png' style="width:28px;height:28px;" />
				<div>菜单3</div>
			</el-col>
		</el-row>
	</el-col>
</template>

<script>
	import utils from '@/utils/utils.js';
	import formDesignerUtil from '@/utils/formDesignerUtil.js';
	export default {
		name: "DesignShortcutMenuComponent",
		props: [
			"componentModel"
		],
		beforeMount() {
			if (this.componentModel.col == undefined) {
				formDesignerUtil.setComponentModelCommonValue(this.componentModel,"col", 12);
			}
		},
		data() {
			return {
				selected: false,
				"propertySet": [{
						"key": "ID",
						"label": "ID",
						"editor": "label"
					}, {
						"key": "title",
						"label": "标题",
						"editor": "text"
					},
					{
						"key": "col",
						"label": "列数",
						"editor": "text"
					},
					{
						"key": "cols",
						"label": "每行列数",
						"editor": "text"
					},
					{
						"key": "dataSourceScript",
						"label": "数据源脚本",
						"editor": "textarea"
					}
				]
			}
		},
		inject: ['children'],
		mounted() {
			this.children.push(this);
		},beforeUnmount() {
			utils.removeArrayElement(this.children,this);
		},
		methods: {
			onClickHandler() {
				formDesignerUtil.componentClickHandler(this);
			},
			setSelected(selected) {
				this.selected = selected;
			},
			getPropertyValue(propertyKey) {
				if(propertyKey=="ID"){
					return formDesignerUtil.getComponentModelPropValue(this.componentModel,"id");
				}else if(propertyKey=="col"){
					return formDesignerUtil.getComponentModelPropValue(this.componentModel,"col");
				}else if(propertyKey=="title"){
					return formDesignerUtil.getComponentModelPropValue(this.componentModel,"title");
				}
				return formDesignerUtil.getComponentModelCommonValue(this.componentModel,propertyKey);
			},
			setPropertyValue(propertyKey, propertyValue) {
				formDesignerUtil.setComponentModelCommonValue(this.componentModel,propertyKey, propertyValue);
				if(propertyKey=="col"){
					formDesignerUtil.setComponentModelPropValue(this.componentModel,"col",parseInt(propertyValue));
				}else if(propertyKey=="title"){
					formDesignerUtil.setComponentModelPropValue(this.componentModel,"title",propertyValue);
				}
			}
		}
	}
</script>

<style>

</style>
